package com.sthz.facepay.mapper;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.sthz.facepay.model.Agent;

public class AgentSqlProvider {

    public String insertSelective(Agent record) {
        BEGIN();
        INSERT_INTO("st_agent");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getAccount() != null) {
            VALUES("account", "#{account,jdbcType=VARCHAR}");
        }
        
        if (record.getPassword() != null) {
            VALUES("password", "#{password,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getAccount_type() != null) {
            VALUES("account_type", "#{account_type,jdbcType=TINYINT}");
        }
        
        if (record.getGrade() != null) {
            VALUES("grade", "#{grade,jdbcType=TINYINT}");
        }
        
        if (record.getCooperation_type() != null) {
            VALUES("cooperation_type", "#{cooperation_type,jdbcType=TINYINT}");
        }
        
        if (record.getState() != null) {
            VALUES("state", "#{state,jdbcType=TINYINT}");
        }
        
        if (record.getLegal_person() != null) {
            VALUES("legal_person", "#{legal_person,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            VALUES("phone", "#{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getIndirect_rate() != null) {
            VALUES("indirect_rate", "#{indirect_rate,jdbcType=INTEGER}");
        }
        
        if (record.getDirect_rate() != null) {
            VALUES("direct_rate", "#{direct_rate,jdbcType=INTEGER}");
        }
        
        if (record.getStart_time() != null) {
            VALUES("start_time", "#{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            VALUES("end_time", "#{end_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getId_positive() != null) {
            VALUES("id_positive", "#{id_positive,jdbcType=VARCHAR}");
        }
        
        if (record.getId_back() != null) {
            VALUES("id_back", "#{id_back,jdbcType=VARCHAR}");
        }
        
        if (record.getBusiness_license() != null) {
            VALUES("business_license", "#{business_license,jdbcType=VARCHAR}");
        }
        
        if (record.getContacts() != null) {
            VALUES("contacts", "#{contacts,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_area() != null) {
            VALUES("agent_area", "#{agent_area,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_address() != null) {
            VALUES("agent_address", "#{agent_address,jdbcType=VARCHAR}");
        }
        
        if (record.getDetailed_address() != null) {
            VALUES("detailed_address", "#{detailed_address,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_phone() != null) {
            VALUES("agent_phone", "#{agent_phone,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_qq() != null) {
            VALUES("agent_qq", "#{agent_qq,jdbcType=VARCHAR}");
        }
        
        if (record.getAlipay_number() != null) {
            VALUES("alipay_number", "#{alipay_number,jdbcType=VARCHAR}");
        }
        
        if (record.getCash_bank() != null) {
            VALUES("cash_bank", "#{cash_bank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardholder() != null) {
            VALUES("cardholder", "#{cardholder,jdbcType=VARCHAR}");
        }
        
        if (record.getId_number() != null) {
            VALUES("id_number", "#{id_number,jdbcType=VARCHAR}");
        }
        
        if (record.getBank_number() != null) {
            VALUES("bank_number", "#{bank_number,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            VALUES("remark", "#{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            VALUES("picture", "#{picture,jdbcType=VARCHAR}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Agent record) {
        BEGIN();
        UPDATE("st_agent");
        
        if (record.getAccount() != null) {
            SET("account = #{account,jdbcType=VARCHAR}");
        }
        
        if (record.getPassword() != null) {
            SET("password = #{password,jdbcType=VARCHAR}");
        }
        
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getAccount_type() != null) {
            SET("account_type = #{account_type,jdbcType=TINYINT}");
        }
        
        if (record.getGrade() != null) {
            SET("grade = #{grade,jdbcType=TINYINT}");
        }
        
        if (record.getCooperation_type() != null) {
            SET("cooperation_type = #{cooperation_type,jdbcType=TINYINT}");
        }
        
        if (record.getState() != null) {
            SET("state = #{state,jdbcType=TINYINT}");
        }
        
        if (record.getLegal_person() != null) {
            SET("legal_person = #{legal_person,jdbcType=VARCHAR}");
        }
        
        if (record.getPhone() != null) {
            SET("phone = #{phone,jdbcType=VARCHAR}");
        }
        
        if (record.getIndirect_rate() != null) {
            SET("indirect_rate = #{indirect_rate,jdbcType=INTEGER}");
        }
        
        if (record.getDirect_rate() != null) {
            SET("direct_rate = #{direct_rate,jdbcType=INTEGER}");
        }
        
        if (record.getStart_time() != null) {
            SET("start_time = #{start_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getEnd_time() != null) {
            SET("end_time = #{end_time,jdbcType=TIMESTAMP}");
        }
        
        if (record.getId_positive() != null) {
            SET("id_positive = #{id_positive,jdbcType=VARCHAR}");
        }
        
        if (record.getId_back() != null) {
            SET("id_back = #{id_back,jdbcType=VARCHAR}");
        }
        
        if (record.getBusiness_license() != null) {
            SET("business_license = #{business_license,jdbcType=VARCHAR}");
        }
        
        if (record.getContacts() != null) {
            SET("contacts = #{contacts,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_area() != null) {
            SET("agent_area = #{agent_area,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_address() != null) {
            SET("agent_address = #{agent_address,jdbcType=VARCHAR}");
        }
        
        if (record.getDetailed_address() != null) {
            SET("detailed_address = #{detailed_address,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_phone() != null) {
            SET("agent_phone = #{agent_phone,jdbcType=VARCHAR}");
        }
        
        if (record.getAgent_qq() != null) {
            SET("agent_qq = #{agent_qq,jdbcType=VARCHAR}");
        }
        
        if (record.getAlipay_number() != null) {
            SET("alipay_number = #{alipay_number,jdbcType=VARCHAR}");
        }
        
        if (record.getCash_bank() != null) {
            SET("cash_bank = #{cash_bank,jdbcType=VARCHAR}");
        }
        
        if (record.getCardholder() != null) {
            SET("cardholder = #{cardholder,jdbcType=VARCHAR}");
        }
        
        if (record.getId_number() != null) {
            SET("id_number = #{id_number,jdbcType=VARCHAR}");
        }
        
        if (record.getBank_number() != null) {
            SET("bank_number = #{bank_number,jdbcType=VARCHAR}");
        }
        
        if (record.getRemark() != null) {
            SET("remark = #{remark,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            SET("picture = #{picture,jdbcType=VARCHAR}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}